package jgamio.framework.application;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;

import jgamio.framework.application.exceptions.EnumDispatcherNotDefined;

public class EnumDispatcher
{
	private Hashtable<Component, ClientEnumParent<?>> enumDispatchers = new Hashtable<Component, ClientEnumParent<?>>();
	
	public void addEnumDispatcher(Component component, ClientEnumParent<?> enumInstance)
	{
		this.enumDispatchers.put(component, enumInstance);
	}
	
	public ClientEnumParent<?> getEnumDispatcher(Component component) throws EnumDispatcherNotDefined
	{
		if (enumDispatchers.containsKey(component))
		{
			return enumDispatchers.get(component);
		}
		else
		{
			throw new EnumDispatcherNotDefined("Enum dispatcher for specified component (" + component.getIdentifier() + ") was not found.");
		}
	}
	
	public boolean hasEnumDispatcher(Component component)
	{
		return enumDispatchers.containsKey(component);
	}
}
